Order alias expansion by reverse topological sort

TODO: Write up a good commmit message.