Porting code over from pagerlib, so that this modular code is even more modular