Refactoring

Bit of a refactor/rewrite on some of the components to get rid of a bunch of race conditions. A lot of the logic changed from 0.9.5.