Add specs. Fix some bugs