Fixed a lot of things and properly implemented the Flags.