Minor code cleaning and corrections (global)