Restructured code and some cleanup.
Added custom user-agent