in reply to Code reuse and clean packages
One way to approach the problem is to refactor according to some QA-style questions:
How hard would it be to debug this chunk'o'code?
How hard would it be to explain this code to a newbie?
How hard would it be to reproduce an error condition in this code?
How hard would it be to test this chunk'o'code?
Whenever the answer is "very hard"-- refactor; extract; simplify; document.
From your description (useful code!) this might not be as hard as it sounds, once you dig in with a particular set of criteria in mind.