Refactor basic blocks to use python ast nodes