Added casting for foreach, changes to preprocessor