improve REM handling