improved semantics visitor, merged some changes