Refactor to build as Gem