Code Cleanup and GUI restore