Refactor message handling so that message buffering and window handling are in the main window code, leaving only message window rendering to the platform code.