Remove race condition waiting for proper event instead of fixed time.
Merge pull request #77 from lapo-luchini/fix_modal

Remove race condition waiting for proper event instead of fixed time