Rotate/shift operations, bug fixes