Fixed some bugs caused by me being an idiot.