Fixing keystream generation