Did a bunch of things I'm not proud of, but it's functional now