Refactors and updates code.