Starting to factor out Ruby code into separate pieces.