bed::CachedStmt, various fixes & improvements