Cleaned up Rcode_ssn.R