Minor bug fixes along with error logging after each SQL command.