Updated checks for division by zero
Fix horrible bug where ctx_switch_half does not restore context
Updated offset to be volatile