Added template support. Fixes #3