Cleanup a few unnecessary flags. Still needs some work on the logic to make it work properly.