Cleaning up addBlock code

Potential fix for #16's crash, and more informative exception if not