refactor Layout, remove sortChildren and unify doLayout