lots of cleanup

@dtornow please check that i didn't break anything. Once that's settled I would like to add eslint to make you respect guidelines ;) and immediately start writing tests!