Tidyed up a lot and added support for the other flags