Fixed pagination and query problems.