Fixed several defects