Huge refactoring. Implement a correct write throttle, closed #18