added state information, cleaned some things up