Some improvements. Hangs on test.