Changed several defines to enum. Added code to take advantage of runtime flags