Security fix & minor update

Fixing a possible sql injection.
Improving Presence management