Visitor cleanup

Some useful refactorings I did when implementing #173.