fixed stuff Emerson did sloppily
auto-formatted all of the code so it looks pretty