Moved code from SQLite to Rserve