Some security issues fixed plus re-factoring.