Use more library functions; generalized to 2^k-PSK