some structural changes to logging in preparation of a big revision