Improved message handling. Removed a pointless variable