Fixed missing directory error

Also moved the creation of the static folder to the synchronous portion
of the function