context operations: add extra safety checks