Code cleanup in widgets