added lots more code for parsing and handling blocks.