cleanup, fixes, and optimization to offline explosion protection code