Refactoring

Moved gathering up the hiearchy and fixed a few things in the factory.