Improved programmatic structure and error handling.

Restructured application with "__name__ == '__main__'" per convention.
Wrapped credential prompt in function. Added notification to user if
credentials rejected by server.