Error reporting and bugfixes