Added a patch for older versions of last_state