Minor optimization for function/unique_function

(cherry picked from commit de516984abde5b8c6172992ae08ec7fb7d3b2130)
missing boost::scoped_ptr includes

(cherry picked from commit 63c64f5cc2152439c0a1e08b566b27724a1bd23b)
Some future on_completed callback cleanup

(cherry picked from commit ad85d0ed1d291b153c5c3e9ae072f39420754284)