it is pointing to master instead of the catalog, as the catalog is generated into the query, and you can have multiple catalogs in your project so it's unclear what the 'first' catalog is. 'master' always connects.
If you want to replace 'master' with a catalog name, because your query doesn't have catalog names, do:
var databaseMetaData = project.MetaData.GetMetaDataForDriverID(driverID);
databaseMetaData contains all metadata for a given driverid, e.g. the PopulatedCatalogs property which contains all catalogs in the meta-data read from the db.
TdlEmitTimeDateInoutputFiles is a project setting now, so you should obtain it by reading the "TdlEmitTimeDateInOutputFiles" from the project settings:
var emitTimedateInOutput = currentProject.GetRealBoolSettingValue("TdlEmitTimeDateInOutputFiles");
Please see the EF / NH / L2S templates for examples, these are all written in .lpt