Code cleaning and refactoring.

Added local root nodes.