Moving flag setting to debug