new login handling, also fixed some event-releated bugs