Really need unit tests on this.