removed old error handling; slightly better calculation
added missing error codes