Don't let a statement be prepared twice

PostgreSQL doesn't like that.
Corrected minor mistakes