Feature/speedup flagops

I think this is ready for merge.
migration can come on a different pullreq.