Fixed bugs in conversion to and from r/a