Fixed payload-length error. Fixed checking of return parameters. Removed some printing.