Fix some bugs found in vs.