Updated to have maxvalue
Converted to using statusenum for everything and general tidy