backports of modifications from the officialy merged msf module