ENH : refactor CSP code
merged conflicts