Some corrections for the main code