Various performance/security fixes.