Exception class added; Some error handling; small bugfixes