Fix key generation (missing long cast)