That's an insane dosage of melatonin. I would stop taking it for a few weeks/months, and I would never recommend someone to take more than 10g MAX of melatonin per night. Have you looked into other options for sleep aids? ZMA can be helpful, as well as Ashwagandha for reducing stress and providing a calming/relaxed feeling.
If your libido is low and things seem off at 24, I would go to your doctor and have your bloodwork done. If you've been dieting for a long time or if you haven't given your body adequate rest and recovery outside of the gym, its possible that you need to pull back on diet/training and let your body recover. Libido shouldn't be an issue at 24, so I would highly suggest seeking a doctor to figure out what's wrong.
As far as supplementation goes, definitely cut out the high dose of melatonin. You could look into a product like Alphamax XT that includes both ZMA and Ashwagandha, which can both help to provide better sleep. Alphamax XT also contains ingredients to increase natural test, limit cortisol and estrogen production, and can help boost libido. This would be a good product to consider for what you've been experiencing, but I would see your doctor first before trying any OTC products to try and fix your sleep/libido problems