Layout, functions and tree prepared