Fixed this up, it now works "perfectly"*
TODO: TESTS, automate everything I did to test that it actually works.