Reorganized and documents more code.