Fized a few bugs