Fixed some bugs (I think)