Bug fixes. All tests passing now.