Migrated pmrsa code from Sourceforge