Fixing some bugs with `when` and `then` not behaving with imidate return values