Code cleaning and documentation fixes