minor corrections

fix indentations and remove useless spaces
Various improvements

RAM usage was improved, together with other aspects