Various cleanups for errors