Revision n. 3

Some cleaning and debugging done