smattering of bugfixes