Tidy up layoutstream

Refactored the layoutStream to use promises instead of the callback pyramid mess. Also changed the order of rendering: Now the template is processed before the layout. This way data created in the template processing can be available to it's wrapping layout.