bug fixes, cleanups