Cython implementation for SSD; other minor fixes