big set of bugfixes per john's notes