Refactor code to separate UI from logic code, renamed variables for overall naming consistency, tiny code polish