finished cleaning everything except template matching