fix broken -i, adopt template system