Added components and modals. Fixed bugs with layout

Now can add elements as modal windows or components. Fixed a bug with
the layout when a lot of horizontal nodes were added or multiple
top-level nodes existed. Added expand/collapse of a node.