move to sphinx documentation

mainly for documentation + some clean up of the API & implementation.