Fixed reentrance bug