Refactor MotionDetector

Add comments and change threshold to be a percentage, so that it is easier
to understand what it does.