Fixed template to remove extra commas, also now works with custom table names.