>> "(it was) a little hurtful"

>> "(I had held off charging till the company was on more solid ground)"

>> "Am I the 'bad friend'?"

Those comments are a red flag to me that you are confusing business with personal relationships, it will always cost you money. I'm curious to know what your upbringing was like. I am speaking from experience here. I'm not saying that you fit into this model (I don't know you), but, it has been my experience that people from codependent families tend to fall into this trap.You are a gifted programmer, but, you struggle to understand how to appropriately bond with people.

You are woking in the same physical space, you see them, you know about their lives and families so you assume because of that you are 'friends'. You may be friendly but you are not there together because you are friends. Your bond is that you all earn a living there, that's it. Later, you may become friends, but that takes time.

A better way to conduct yourself is to put on a 'work persona'.

You are not the same person in every situation right? You do not walk around town in your underwear like you might at home. You do not drink soup from a bowl in a restaurant like you might at home. You don't talk to your mother like you do a stranger right? You are many different people already. You may not consciously choose to change your speech when you talk to your mother or a baby or a dog or a cop or a stranger but you do it. So recognize that ability and use it.

Your work persona will have a different vocabulary, wardrobe, everything.

Your work persona should be professional but warm. Professional means good manners and doing what you are supposed to do even if you do not feel like it. It does not mean cold and without personality.

If you are acting like a professional you have every right to expect others to act like professionals and you should interact with them like they are a professional.

It is at this point (pro to pro) that the lack of payment should have come to a head. When you are not being paid, stop working. Do it in a friendly way, don't shout or storm out. Give a company a small grace period (maybe a week) but even that is pushing it. Then simply say to whoever you report to: I'm unable to work here without pay, I'm sorry. If you can pay me I will continue work. If they say "we will pay next week please keep working" You say: 'I will keep working next week when I am paid'.

Seriously, even if you GET THE FEELING like you aren't going to get paid (like you said) that is the point to start saying something.

Someone here mentioned a lawyer. Let me tell you something from experience, don't rely on that in place of speaking up. Even if you have an airtight contract written by the best lawyer in the country and everyone in the company signed and agreed to it, A CONTRACT IS NOT MONEY. In fact, enforcing that contract is going to cost you money. It costs $250 to sue someone in America and 99.9% of all lawsuits are settled before they go to trial. That means the only thing that matters is who has the most money to fight over the contract. If it is you (a person) versus your work (a company) you probably do not have the money to fight over a contract. Start speaking up early and leave if you aren't paid.

I'm going to go out on a limb here and say what I actually think happened. I think you rewrote their code without explicitly being asked to do so. Programming is fun, you saw that you could make a big impact so you just did it yourself and it worked! However, from their perspective you did something they didn't actually ask you to do, so, they feel it doesn't have value. You also didn't press for payment which further fuels their feeling (not fact) that you did not contribute value.

Also, the product existed before you and there are a lot of people who make that product work regardless of who wrote it: sales, support, management. Remember that, they sure do.

If you are so talented that you can rewrite an entire production grade codebase: go work for someone who pays you or work for yourself.

Honestly, and I mean this in the most sincere empathetic way I know how to say it: you sound a bit inexperienced and a little immature. This experience will help you grow. Remember how it feels to be disrespected and not paid and use that horrible fucking feeling to protect yourself in the future. I'm not saying be jaded and cynical, I'm saying just act as a professional (especially when it is difficult to do so) and you will be amazed at how things like this stop happening.

One final point and I will hit 'reply' and count the downvotes: How long did it take you to be able to do what you do? A thousand hours? Five thousand? Ten? More?

Whatever it is: THAT is what you are selling; your experience.

It is confusing because programmers are used to just spending time at a computer without any expectation of being paid. We read and code and try things and chat online about it, all in a self-education mode learning on our own because it is fun. Then we go to work and, again, I sit at a desk, I open my favorite editor and write in my favorite language and I'm having fun again! I'm just in a different building. So when I don't get paid it actually feels kind of OK because I am used to doing this for free. Oy.

The difference is now that you are working for someone they are getting the benefit of all that sweat equity. Name another industry where someone has a thousand hours of experience and they are expected to work for free. It doesn't exist.

Ask for payment, you earned it. If you do not get paid on time then walk. If you see a coworker not getting his rightfully earned pay, that company is broken and if you don't move on you will eventually be next to not get paid.

You are a talented developer, businesses need talented developers so they hire them. After that, your experience there is largely up to you.

Be a professional and walk if you are not paid in timely manner. Always speak up for yourself, look out for yourself, and if you see others being treated poorly (and it's permitted) find another job.