Clean up some logic