Added generate template. Fixed key argument.