Fixed sync/async issues
Moved requires to the top of the document