Moving flags into global structure
Refactoring a bit
-Added notion of a machine which has instances