better errors, cleanup