made 'receive()' blocking, fixed a number of bugs