preliminary gem support

It actually works but some more work needs to be done