Work on adapting the examples to new api,
various template code fixes