Move flag-related code into new pkg package

proxyFlag?