Clean up main function
First version of fancier ui
Move common functions to util.py