Minimal attempt to make this code more readable.