Factored out rpc code to its own module

- Added support for optional socks proxy
- Added support for change directory (cd)