added some user support and cleaned up message loop