improved dispose behaviour