Code cleanup and UI tweak