slight tweaks to sql calls for performance
merged log changes