Moved notify() calls after everything else.