Fix ifdef and other cleanup