Fix 3 potential security problems.

Thanks to @iurisilvio for pointing me in this
direction.