Fixes in RWR function.