cleanup and pagination

commits are small so you can review each change.