Fixed promise chaining.
Fixed appdatadir for mac.
Cleanup.