Replace class with simple function.

For easier decomposition.