Fixed some bugs, refactored some stuff