Correction of many bugs, change in some codes, adding some tests with