Consolidating flag code, fixing typos