Fixed the problem with editing two widgets. Cleaned up the code.