Changed calc_psn to use objects for IO