Fixed most warnings for a safer code