Messaging, refactoring

Implimented crude RPC based messaging. Refactoring.