Tweaking various things

Removing the DebugSQL stuff
Fixing bugs in prev/next functionality