better err msgs, fix template bug