Restructure using require
Add when and require
Quick and dirty wrapper using promises
Fixed path to when