all basic fixes in

not thoroughly tested for large numbers of blocks