Its usually recommended to unhook the battery when touching anything electrical just for safety. Both your safety and the equipments safety.
Keep in mind when cleaning the maf, don't touch the wires with anything, just spray it down very thoroughly and make sure it's bone dry before you plug it back in.
As for the o2 sensor, either leave it alone or just replace it imo.