Fix unsigned short reading.
Refactor, basic login handling.