Added full support for clusters and cgroups, and cleaned up the code a bunch.