Refactor sqlite API, simplify lib