Last successful login is recorded

Code cleanup and commenting, along with fixing an oversight where the
last login date was not set