some bugfixes on send/receive by refactoring