Deferred functions using promise

Replace internal usage of Deferred with Promise