Fix security issues found by brakeman