added (what ought to be) complete logging throughout