Fixed several bugs in receive
Fixed several bugs in receive