fix fitting bug & other misc improvements