Refactored for visitor pattern.