Moved some of these to functions as local variables instead of class variables.