Did you ask them that you planned to clean the code before hand? Take the case of the company: they must be thinking something like "this guy decides to clean the code and this delays the project for ages". If you are freelancing (I am not, so take this with a grain of salt), isn't the best strategy to deliver first?
Having say that, I know how terrible it is to work on some crappy legacy code and can certainly understand your decision. Good luck!
Having say that, I know how terrible it is to work on some crappy legacy code and can certainly understand your decision. Good luck!