Added some error handling for faulty bytes and connection errors