improve visitor inheritance and many minor code cleanups