Lots of code cleaning