Builds internal data structure and layer DOM.