Adding sql schema and fixing some security issues