Split lib.rs into modules.
Moved code from lib.rs into modules.