Add RuboCop, fix violations

@emerose more stuff, apparently my last change didn't include what we need
@emerose this is the part that fixes ruby compatibility (it's also about 2x faster than the old implementation)