cleanups and stripping out dead code