Several bugs correction