Refactoring. Merge changes from main repo. Add custom pageChange event