Added fixes and tests.