Procedures adapted to updated directory structure

Many bug fixes and code cleaning