CB-6326 Removed functions, fixed indent

-Removed functions: appendLog, writeLog, delLog.
-No indent on top-level functions
-Changed for loop from for(var t in promises) to
promises.forEach(function(p))
-Other minor changes