fix few bugs on MaxOSX