Fix issue with 'template' dependencies. General clean up.