Fixed by making this into an extension.