Remove unneeded code and refactor.