Some changes to make custom template object instantiation to work