Avoid a crash by checking the container
Efficiency improvements

Many changes made to try to improve the execution time of the
WordDisplayWidget constructor.