Some code cleanup, added debugging outputs to policygen