Giant patch to use blocks

Please take a look at this, i'm no good with c++.