Converted to be a gem instead, as Rails is too heavy for this.