Added avoid_zero template function and modified wrapper.cu for use it