Add new debug page and tidy up a few things