Gem cleanups and refactorings