Simplify and restructure code.