Added exception classes
Fixed some issues