some errors still result in exit -1, which should be replaced by throwing exceptions
some errors still result in exit -1, which should be replaced by throwing exceptions