improved wall avoidance and program exit