Remove debug prints and add sanity check when switching pages.