Simplify the code to keep it less than 1k lines.