Fix #26 + bug fixes

Fixed Bug with last commit on messaging. 
Cleaned up code.