Big code refactor.