Added count of devices using a template when editing a template.

Fixes #458