Artisan optimize timeout

Fixed issue where artisan optimize would sometimes time out when generating classes.

This issue has been flagged before in #1050 but it doesn't look like it was fixed back then