Fixed foundation normalization bug. Fixed compilation errors in VS 2012