Better logging, small performance tweak