major reorganisation to implement webapps as per docs/webapp-packaging.md