Refactoring code in RPS branch

@gabebw @jsteiner
I recommended it, sorry. It felt right!