Refactors again and removes useless code