more cleanups and tests