code cleanup and design tweaks