Refactored receive loop again.