Minor code cleanup, and improvements to Message API