fix to ensure state.env and state.env.bolt is set before deleting keys