Made functions for doing most of the work for new functionality in model.