Refactored mesh parsing code.