Added idFactory and fixed classes to work with it. Also added tests.
Did some stuff to layout stuff.