JS bugfixes in pagination loop.