Close to getting it to work. Removing a lot of debug stuff after this commit