Moves AST expansion code into runtime package, since this is
the only place where it is relevant.

Fixes documentation to reflect this change, along with
some other cosmetic changes.