Moved old client out of client.py

This stuff is not even used by Orphilia, but I'd probably try to reuse
it later, so I moved it out to reference code directory.
Quick code cleanup

Changing some variable names and stuff, make this more readable and
maintanable.