Removed some closures, moved promises to main file.