fixed free condition and test with and without class cache