Insomnia is a common problem, and I am glad to hear that you are taking the most important measures already (such as avoiding caffeine, etc). There are additional measures that might be beneficial in your situation, and your
primary care doctor will be able to discuss these with you in more detail, which might allow you to avoid medications altogether.
If your melatonin is providing symptom relief for you, then this might be a good option. While there are no known complications with this medication, there is not a large amount of evidence regarding the long term use, although it is generally considered to be relatively safe. The maximum and recommended dose should be indicated on the box of the product that you are purchasing. In general, a dose of 0.5 to 10mg taken at night is recommended.
Your brain actually secretes this hormone as well, as it is responsible for regulating your sleep/wake cycle to some degree. It can be valuable for some people who are seeking to recover quickly from jet lag as well, but should, like all medications, be used in consultation with your physician who knows your personal medical history and situation and can advise accordingly.