Polishing the code, removing some mistakes