Fixed some multithreading issues. Added login.

Threads should now close down properly when the main thread is closed.
Login feature is now operating!