various and sundry bug fixes