Fixed various defects