improved error classes
merge most recent changes with my error catching