Implemented Root.UI

Also refactored some things.