Move implementation to the gems

Now we keep only the common code and move the specific code to the gems