Major refactor of block code. Reduces a lot of repeat code