enable gem plugin and some minor refactoring