Fixed some return types, added error_msg for failed receive and some more comments