backport recent changes in PC target version
bugfix : generate "else"
implemented randon + fixed rest_elapsed_from_