Implementation of promises, simplification of sync