Fix bug in array padding, template matching