Bug Fix: Prevent failure when executing SQL string (fixes #7)
Tidy up the code and make it consistent with the rest of the codebase