Fixed compile errors

Fixed compile errors in add_block and cleaned up code