changes from last patchset: patch 1/4 - just changelog changed, patch itself left untouched. patch 2/4 - do not forward static functions declaration and rearrange code as James Hawkins and Rob Shearman requested. patch 3/4 - check correct last error code as Rob Shearman requested. patch 4/4 - just rediffed.