Common file, Login

Moved all common code to a seperate file, created a login system