Fixed some bugs, still a lot of work to do