added table names option and fixed advanced options to use prepared statements