Fixed NPE.
Fixed (most) failing tests.