Correction of several bugs