Executable invalid message

Implemented error logging when an InvalidMessage is received.  Also did some minor refactoring and code analysis.