Encapsulating code that would cause problems for headpin