Refactoring code in RPS branch

@gabebw @jsteiner
your indentation is wonky here.