Implemented most of Pierre's comments