It's extremely hard to lose weight and gain muscle at the same time. It can be done, but you have to be extremely meticulous.
Keep your carbs at around 100-200 grams per day, depending on your carb tolerance. Replace the calories from the carbs with protein.
As you increase muscle mass, your metabolism will increase. Thus, it will be easier to not only lose weight, but also keep the weight off.
If you are on an extreme calorie reduction diet, sip BCAA's throughout the day to preserve your muscle mass. There's nothing worse than going from fat to skinny fat. Use the mirror, not the scale to gauge your progress.
Keep it simple. To lose weight, calories burned must exceed calories consumed. Too many people get caught up in the details, and forget that.
Starvation doesn't work. If you drop your calories too quickly, your body will respond by slowing down its metabolism.
Those are just some random tips.