many code cleanups