Trying to fix flag assignments