Replaced magic number with enum value
Errors are now printed with cerr instead of cout