Reiterating what everyone else has said... First, don't construe anything I say as legal advice. You need to consult a lawyer.
Having said that, the one main thing to remember is that if you don't have access to the code, and write everything from scratch on your own, how can anyone claim you have "stolen" their work? Remember, it would be up to them to prove you stole the work, which is harder than you trying to prove you didn't steal it.
BUT... You still need to consult a lawyer if it is that big of a concern for you.