Clean up generateHead() method.