Fixes for the boost-1.39 problem. It is less efficient than what we were doing previously but it works.