Manually merge BlockManager refactor #75

PR #75 was unfortunately not cherry-picked into 0.8.0, which caused a build breakage earlier and now again due to later changes being cherry-picked. This merges #75 and replays #139 on top of it. I have confirmed that #75 has made exactly the changes it did on master. So long as all BlockManager patches from master should have gone into branch-0.8, this PR should do the right thing.