Split update_tables into two methods and clean up the html creation

Don't know why the other 8 commits show up. 8980ffc07105bcdaba7aa443ab4e2c43f9bba447 is the one.