Added discovery of temporary tablespaces; updated template; refactoring