Bugfixes in SQL(ite) code, + small improvements in Record

Signed-off-by: Matthias Stevens <matthias.stevens@gmail.com>