Switched to new exceptions; code cleanup