Fixed some bugs and whatnot