Comments and small optimizations of LayoutNodeCompiler

Documented LayoutNodeCompiler and made code more readable.