Take a look at:
These pieces of code are in need of proper value objects. Refactor the code, introduce objects and make sure that:
- Illegal states cannot be represented by these objects,
- Any domain knowledge you already have or have gained by reverse engineering the snippets will be documented in the tests and classes for these objects.