Move reverse topology code to its own translation unit