cleanups, bug fixes