Replace stringy crap with real bitwise arithmetic

Besides it being retarded to use strings for this stuff, it was broken on JRuby