Fix bug in reading rprim