Cleaned up some functions by using composition.