More documentation and refractoring.