Beginning to split up and clean up code.