Fixed tenantId variable
Removed any reference to safe_mode since it was removed in PHP 5.4.
Moved set_time_limit where it makes sense