Reorganized stuff. Added more testing code.