Gang activity analysis scripts: code refactored