Fixed various bugs, I'm an idiot