a bunch of bug fixes for duplicate login