fix some performance issues