Massive rewrite to use TCP server

- Added Emacs client control
- Removed reliance on some external programs (this fixes some parsing
  issues)