fixed some performance problems