Clean up message handling and fix bugs