Added pagination and cleaned up various bits.