Code cleanup, made dbg.py the main entry point