Fixed some bugs, still not working

Current issue is on line 628.