Added block generation from bitmap. Fixed bugs.