updates stat object, some general code cleanup