Debugging: common code for flags parsing from APS1_DEBUG or --debug