Lots of stuff that I was too lazy to separate into different commits
Apparently I moved a few #includes around and added a function declaration