Bugfixes, overhaul of exception system