Changed to a module based system.

Modules can be loaded and unloaded, and have dependencies (although this
should be improved).
Many of the modules may not work correctly due to the change of
environment.