Roll out optimisation from Core into code

GHC sure is clever.