overhaul of code and slight UI tweaks