Fixes and additions

Added a flags helper class
Changed some error messages to exceptions