Refactor IPC functions, and pull base classes into their own module.

Also update documentation.
PEP8