Reformatted code and fixed widget update