htmlspecialchars and some other fixes