Minor optimizations and external login fixes