This may help you with preservatives: Science-y Hair Blog: Preserving Your Homemade Hair Gels
There are some bacteria and fungi that won't be killed by boiling (that's why we pressure-can non-acid foods - to get a temperature above boiling), but it's more likely it was contaminated after preparation. Here's more about that: Science-y Hair Blog: When Good Bottles Go Bad
Also be sure you wipe down surfaces with bleach solution or isopropyl (rubbing) alcohol to be as sterile as possible. At first it seems like a hassle, but it becomes second-nature quickly. I keep a cleaned-out dish soap bottle with pre-mixed bleach solution on the kitchen counter to make things easier.