cruft removal and better logging