Moved pages management to the toolbar and refactored a bit