Separate Shotgun logic out so it can be used for non-servlet code