Re: Bad knees
Ice, Ibuprofen, perhaps glucosamine/chondroiten supplements, and take a good look at the alignment in your legs, and whether you're over extending your stance, something I'm guilty of. Most definitely warm them up before the class warmup; some teachers don't warmup the knees as much as I need.
Before class I'll take a seat on the mat, legs out, and I raise each leg at the knee, leaving the foot down, and drop the knee, not slam it. For particulars unbeknownst to me, this seems to loosen them up pretty well. I then give a light to moderate clapping sort of massage to the region. I imagine it is the stirring/loosening up of fluids, plus increased circulation, but I'm no pro.
As for ice, consider durable reusable cold packs, something that you can put on your knees at bedtime, rollover in the middle of the night without popping, and put back in the freezer each morning. The more convenient and hassle free you can make this, the more easy a habit it will be to make.