Code cleanup and UI improvements