SQLObjet functionality added, DRY'ed up code