Rearranged ProcessMessage function flow for clarity and less nesting.
Merge pull request #50 from murrekatt/main_cleanup

Rearranged ProcessMessage function flow for clarity and less nesting.