Bugfix / Stephan Peitz and more paranoid error checking