Fixed some bugs, added new handling errors