Add bugfix for wrong page sorting and tree structure