Refactor getBlocks, a cleaner pull

Single clean re-work of
https://github.com/concrete5/concrete5/pull/842
Merge pull request #861 from JohntheFish/patch-11

Refactor getBlocks, a cleaner pull