First commit. Code from pgwrap for modifications e prepare to accept transactions e non thread applications.