Fixed most bugs from import.