Upgrade gem dependencies
Remove code duplication