Add REM detection code
Start to add REM detector to main program (and rename clock_t to myclock_t)