General code cleaning and improved behaviour of path creation.