reorganizes, adds error codes