Fixed some unsafe operations