Add CSP and refactor client accordingly.