getting messy, but these changes allow easy downstream merging