Merged mkoppanen his flag refactor