Merge upstream fixes

Merged upstream bugfixes. Include bug that is currently preventing login on dev.drama9.com

@mcginleyr1 for review