Cleaned up some repetitive code.