Implement epochs; fix integration bugs