Fix a few bugs, WIP on simliarity measure.