Flag Branch Merge

This is the merge of the current master with the flags profile branch. It supersedes this pull: https://github.com/karuto/aig/pull/12.