Added flag report and fixed bugs