Bugfix for the template matching crash.