fix tearing, remove useless code