Fix bug with handling of lastLogin for canshutdown action. Fix a lot of warnings in the process.