Do not deallocate non-existing prepared statement

This is refinement of fix submitted in #107 and fixes #116