Lots of improvements to OPIC sqlite