Reorder code to make SQL logging make sense
Fix issue #17