some minor cleanup, bug fixes