Gem updates, major fixes and refactorings