Move a little specific occurrence logic out of the generated code