Cleanups: move basic block linking to separated function