Made diag_factor a class attribute so it can be changed without passing extra arguments.