Added all of Vinh's changes.