Last commit is not strictly necessary, it was meant to cleanup a bit the logic but it has some issues, I'll try to fix it.
Nevertheless I think something like that could fix the issue, event though I'm not completely satisfied with delaying commands like that. I couldn't think of a better way though.