Rewrite of CDLS in Python.