Created exception class, fixed some bugs