Graphical glitches

I am using the mac os x port of SDL. I ported my game over to SDL from allegro and I have
some issues with the screen updates that worked perfectly in my old version. I am using a
dirty rectangle system. I simply blit to a buffer, then add the rectange to a list, then blit
buffer rectangles to the screen every screen update.

Every once in awhile a rectangle is blit in the wrong place or not at all or i get a "garbled"

My update function goes like this:
SDL_UpdateRects(buffscreen, num_rects, rect_array);
to make sure the buffer is up to date

then run through the rectangle list with a for loop and blit from buffer to screen
each pass I do
SDL_BlitSurface(buffscreen, &blit_rect1, screen, &blit_rect2);

after the loop is done I call
SDL_UpdateRects(screen, num_rects, rect_array);

can someone help understand what is happening.
I thought SDL_UnlockSurface(screen); should be switched with the lock, but no updates
occur on the screen if I switch them.