Refactor HandshakeDetector
[FOLD] shared_handler tidying