[#41] replace instanceof with element and type visitors

also use singletons or properties for visitors and functions