Clean up of the reference implementation.