Fixed some bugs, still with errors