To keep the texture of your spaghetti firm, slightly undercook, just to al dente as they will continue to cook when they go into the oven.
For extra smooth melted cheese, shred your own rather than buying the pre-shredded bags of cheese. Most pre-shredded bags of cheese are coated with anti-caking agents that do not melt as well and can throw off the taste.
If you aren't a fan of ricotta or cannot find it, replace with cream cheese or cottage cheese.
Double the recipe and make a second batch to freeze later!