RRWM added. Some function parameters changed.