model: Fix word edit feature.

It is primarily working but there are still some issues. Committing
partial changes now, will fix rest tomorrow.