Merge from Perforce
Fix some bugs