Fix for #487

In addition to the fix for #487 this has some changes to resolve conflicts and some work on a generalized higher_order_sp function that may be moved into higher_order eventually.