Fixed several bugs and added some exception handling for the model classes