Much more stable version - proper static variables