add some minor optimizations and fix spip empty lines on rewind