Add better exception handling and clean up some uis