bug fixes and other hacks