Add better support for application composition.

Same as #314 but looking to merge to master.