Refactor as AMD Module. Partially complete.