Refactor tmx level parsing code.