Code cleaning and adding missing packages