Refactor to make the code more consistent and clean.