Fixed some bugs in scale estimation