Cleaned everything up to be more in line with Hadley Wickhams R style. (more descriptive function names, 80-ish characters on each line and so forth).