Fix some bugs
Merge from Perforce