Refactor input/output and eliminate old R relics

Refactor input/output and eliminate old R relics