Updated/simplified for systems with block support. For the old macro see the pre-blocks branch.