Code cleanup, moved some local vars to widget prototype.