cleaning up
changing error code flags; will verify later