Replace all uses of old ifX with new if-percent
Break out functions into separate files