Merge pull request #50 from murrekatt/main_cleanup

Rearranged ProcessMessage function flow for clarity and less nesting.
Cleanup of comments and code around sleeping.
Misc small cleanup.
Moved out main loop into run function.
Moved out socket init into own function.
Removed unnecessary assert as it is already in wrapper class.
Removed unused define.