Error reporting and some more fixes