Added Widget interface and classes.

Refactored code to use them.