[Finished #48675561] Pull out some functionality into a gem