UI improvements
Started to un-spaghettify js, hoping to keep it readable and maintainable