Improved on flagging. Debugging last part.