Resolve layout issues, better way of determining selected button, code cleanup