Abstract out a bunch of common functionality in fragments