core: implement 'finally' block extraction