Refactored detector as I plan to introduce different detection algorithms.