Fixed several bugs. Send / receive now works, but termination is broken.