Updated login procedures

Tidied up some of the login code, merged the login encoders (LoginMessage and LoginResponse), and made the code more generic overall.