Several fixes for promises, allow querying its state. More to come...