Bug fix. Unit tests pass