Code cleanup. Added a new debug flag.