Sets up ajax pagination, plus some small tweaks