Added some optimization to YAML loader