Code cleanup, debug work