Refactoring of daemon/* code to support exec and related features

This PR should not affect any existing functionality.

@crosbymichael : As per your request, I have extracted out the refactoring part of #7409 into this PR.


It still can be passed around by type name and fun is that you already named the field by type name :) So, it even easier.