Refactor sample apps and template app to use new structure