Implement prepared statement caching (alternative approach)

This pull request implements #58 in a simpler fashion than #64