debug and code cleanups