Removed geometric bias of detectors

Surplus features are now removed randomly. Several code improvements
have been made that may increase speed, but mainly to improve
readability.