fixing flag refs