Added some bugfixes for read errors