Cleaning, refactoring and little more fault tolerant