Improved prototype. Doesn't use visitor/related API.