Fix message sending bug (also some indentation cleanup)