diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp
index d8e337e231a43fef2e78bd64b26c9c667cf50240..a661d52b7f0d239d20dbd598237efd03e6c5727a 100644
--- a/indra/llinventory/llsettingsbase.cpp
+++ b/indra/llinventory/llsettingsbase.cpp
@@ -572,7 +572,7 @@ F64 LLSettingsBlenderTimeDelta::calculateBlend(F64 spanpos, F64 spanlen) const
 
 void LLSettingsBlenderTimeDelta::update(F64 timedelta)
 {
-    mTimeSpent += F64Seconds(timedelta);
+    mTimeSpent += LLSettingsBase::Seconds(timedelta);
 
     if (mTimeSpent > mBlendSpan)
     {
diff --git a/indra/llinventory/llsettingsbase.h b/indra/llinventory/llsettingsbase.h
index 0b99166a86a95b07885ffff4df808fa69eea7203..6f072a4e507c966ad79fe66987514c3908979cca 100644
--- a/indra/llinventory/llsettingsbase.h
+++ b/indra/llinventory/llsettingsbase.h
@@ -41,6 +41,7 @@
 #include "llquaternion.h"
 #include "v4color.h"
 #include "v3color.h"
+#include "llunits.h"
 
 #include "llinventorysettings.h"
 
@@ -54,6 +55,8 @@ class LLSettingsBase :
     friend std::ostream &operator <<(std::ostream& os, LLSettingsBase &settings);
 
 public:
+    typedef F64Seconds Seconds;
+
     static const std::string SETTING_ID;
     static const std::string SETTING_NAME;
     static const std::string SETTING_HASH;
@@ -344,7 +347,7 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender
         mLastUpdate(0.0f),
         mTimeSpent(0.0f)
     {
-        mTimeStart = F64Seconds(LLDate::now().secondsSinceEpoch());
+        mTimeStart = LLSettingsBase::Seconds(LLDate::now().secondsSinceEpoch());
         mLastUpdate = mTimeStart;
     }
 
@@ -367,10 +370,10 @@ class LLSettingsBlenderTimeDelta : public LLSettingsBlender
 protected:
     F64                     calculateBlend(F64 spanpos, F64 spanlen) const;
 
-    F64Seconds              mBlendSpan;
-    F64Seconds              mLastUpdate;
-    F64Seconds              mTimeSpent;
-    F64Seconds              mTimeStart;
+    LLSettingsBase::Seconds mBlendSpan;
+    LLSettingsBase::Seconds mLastUpdate;
+    LLSettingsBase::Seconds mTimeSpent;
+    LLSettingsBase::Seconds mTimeStart;
 };
 
 
diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp
index 577b12b03170db7e745c8e229237328b803c4ce3..6f4e70e98f89c8c6cf0fe6f218d6dace7e815935 100644
--- a/indra/llinventory/llsettingsdaycycle.cpp
+++ b/indra/llinventory/llsettingsdaycycle.cpp
@@ -89,13 +89,13 @@ const std::string LLSettingsDay::SETTING_KEYHASH("key_hash");
 const std::string LLSettingsDay::SETTING_TRACKS("tracks");
 const std::string LLSettingsDay::SETTING_FRAMES("frames");
 
-const S64Seconds LLSettingsDay::MINIMUM_DAYLENGTH(300); // 5 mins
-const S64Seconds LLSettingsDay::DEFAULT_DAYLENGTH(14400); // 4 hours
-const S64Seconds LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days
+const LLSettingsDay::Seconds LLSettingsDay::MINIMUM_DAYLENGTH(300); // 5 mins
+const LLSettingsDay::Seconds LLSettingsDay::DEFAULT_DAYLENGTH(14400); // 4 hours
+const LLSettingsDay::Seconds LLSettingsDay::MAXIMUM_DAYLENGTH(604800); // 7 days
 
-const S64Seconds LLSettingsDay::MINIMUM_DAYOFFSET(0);
-const S64Seconds LLSettingsDay::DEFAULT_DAYOFFSET(57600);  // +16 hours == -8 hours (SLT time offset)
-const S64Seconds LLSettingsDay::MAXIMUM_DAYOFFSET(86400);  // 24 hours
+const LLSettingsDay::Seconds LLSettingsDay::MINIMUM_DAYOFFSET(0);
+const LLSettingsDay::Seconds LLSettingsDay::DEFAULT_DAYOFFSET(57600);  // +16 hours == -8 hours (SLT time offset)
+const LLSettingsDay::Seconds LLSettingsDay::MAXIMUM_DAYOFFSET(86400);  // 24 hours
 
 const S32 LLSettingsDay::TRACK_WATER(0);   // water track is 0
 const S32 LLSettingsDay::TRACK_MAX(5);     // 5 tracks, 4 skys, 1 water
@@ -465,7 +465,7 @@ LLSettingsDay::CycleTrack_t &LLSettingsDay::getCycleTrack(S32 track)
 //=========================================================================
 void LLSettingsDay::startDayCycle()
 {
-    F64Seconds now(LLDate::now().secondsSinceEpoch());
+    LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch());
 
     if (!mInitialized)
     {
diff --git a/indra/llinventory/llsettingsdaycycle.h b/indra/llinventory/llsettingsdaycycle.h
index 5e6fc7f21d67c807f72ed5a55955dcebc208ed84..0929cff87c5ceb2009b48eb1364e6761623154d1 100644
--- a/indra/llinventory/llsettingsdaycycle.h
+++ b/indra/llinventory/llsettingsdaycycle.h
@@ -48,13 +48,16 @@ class LLSettingsDay : public LLSettingsBase
     static const std::string    SETTING_TRACKS;
     static const std::string    SETTING_FRAMES;
 
-    static const S64Seconds     MINIMUM_DAYLENGTH;
-    static const S64Seconds     DEFAULT_DAYLENGTH;
-    static const S64Seconds     MAXIMUM_DAYLENGTH;
+    // 32-bit as LLSD only supports that width at present
+    typedef S32Seconds Seconds;
 
-    static const S64Seconds     MINIMUM_DAYOFFSET;
-    static const S64Seconds     DEFAULT_DAYOFFSET;
-    static const S64Seconds     MAXIMUM_DAYOFFSET;
+    static const Seconds MINIMUM_DAYLENGTH;
+    static const Seconds DEFAULT_DAYLENGTH;
+    static const Seconds MAXIMUM_DAYLENGTH;
+
+    static const Seconds MINIMUM_DAYOFFSET;
+    static const Seconds DEFAULT_DAYOFFSET;
+    static const Seconds MAXIMUM_DAYOFFSET;
 
     static const S32            TRACK_WATER;
     static const S32            TRACK_MAX;
@@ -129,7 +132,7 @@ class LLSettingsDay : public LLSettingsBase
 private:
     CycleList_t                 mDayTracks;
 
-    F64Seconds                  mLastUpdateTime;
+    LLSettingsBase::Seconds     mLastUpdateTime;
 
     void                        parseFromLLSD(LLSD &data);
 
@@ -137,10 +140,6 @@ class LLSettingsDay : public LLSettingsBase
     static CycleTrack_t::iterator   getEntryAtOrAfter(CycleTrack_t &track, F32 keyframe);
 
     TrackBound_t                getBoundingEntries(CycleTrack_t &track, F32 keyframe);
-
-//     void                        onSkyTransitionDone(S32 track, const LLSettingsBlender::ptr_t &blender);
-//     void                        onWaterTransitionDone(const LLSettingsBlender::ptr_t &blender);
-
 };
 
 #endif
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp
index 6c5ed8f12b4c5035762cdacf751b3a3d8d240e80..b6320e094251f9225d02120dc5b39c4157eb98cf 100644
--- a/indra/llinventory/llsettingssky.cpp
+++ b/indra/llinventory/llsettingssky.cpp
@@ -790,7 +790,7 @@ bool LLSettingsSky::getIsMoonUp() const
     return moonDir.mV[2] > NIGHTTIME_ELEVATION_SIN;
 }
 
-void LLSettingsSky::calculateHeavnlyBodyPositions()  const
+void LLSettingsSky::calculateHeavenlyBodyPositions()  const
 {
     if (!mPositionsDirty)
     {
@@ -811,7 +811,7 @@ void LLSettingsSky::calculateHeavnlyBodyPositions()  const
 
 LLVector3 LLSettingsSky::getLightDirection() const
 {
-    calculateHeavnlyBodyPositions();
+    calculateHeavenlyBodyPositions();
 
     // is the normal from the sun or the moon
     if (getIsSunUp())
@@ -955,13 +955,13 @@ LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const
 
 LLVector3 LLSettingsSky::getSunDirection() const
 {
-    calculateHeavnlyBodyPositions();
+    calculateHeavenlyBodyPositions();
     return mSunDirection;
 }
 
 LLVector3 LLSettingsSky::getMoonDirection() const
 {
-    calculateHeavnlyBodyPositions();
+    calculateHeavenlyBodyPositions();
     return mMoonDirection;
 }
 
@@ -1008,7 +1008,7 @@ void LLSettingsSky::calculateLightSettings() const
         return;
     }
 
-    calculateHeavnlyBodyPositions();
+    calculateHeavenlyBodyPositions();
 
     mLightingDirty = false;
 
diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h
index ee201f41227b336caf934847690a6ce85a8dd2c8..6e532eba5515fa96a1a50e5445294d1ab55f34d2 100644
--- a/indra/llinventory/llsettingssky.h
+++ b/indra/llinventory/llsettingssky.h
@@ -423,7 +423,7 @@ class LLSettingsSky: public LLSettingsBase
     LLSettingsSky();
 
     virtual stringset_t getSlerpKeys() const override;
-
+    virtual stringset_t getSkipInterpolateKeys() const;
     virtual void    updateSettings() override;
 
 private:
@@ -434,7 +434,7 @@ class LLSettingsSky: public LLSettingsBase
     static LLSD absorptionConfigDefault();
     static LLSD mieConfigDefault();
 
-    void        calculateHeavnlyBodyPositions() const;
+    void        calculateHeavenlyBodyPositions() const;
     void        calculateLightSettings() const;
 
     mutable LLVector3   mSunDirection;
diff --git a/indra/llinventory/llsettingswater.h b/indra/llinventory/llsettingswater.h
index acae903e92b4c9ee6d9027714b22b2c7c66ebfc9..35e5b7bcf6c7b830854763259664ab2e29c8e5ce 100644
--- a/indra/llinventory/llsettingswater.h
+++ b/indra/llinventory/llsettingswater.h
@@ -76,22 +76,22 @@ class LLSettingsWater : public LLSettingsBase
         setValue(SETTING_BLUR_MULTIPILER, val);
     }
 
-    LLColor3 getFogColor() const
+    LLColor3 getWaterFogColor() const
     {
         return LLColor3(mSettings[SETTING_FOG_COLOR]);
     }
 
-    void setFogColor(LLColor3 val)
+    void setWaterFogColor(LLColor3 val)
     {
         setValue(SETTING_FOG_COLOR, val);
     }
 
-    F32 getFogDensity() const
+    F32 getWaterFogDensity() const
     {
         return mSettings[SETTING_FOG_DENSITY].asReal();
     }
 
-    void setFogDensity(F32 val)
+    void setWaterFogDensity(F32 val)
     {
         setValue(SETTING_FOG_DENSITY, val);
     }
diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp
index b027a2401757493fb7379d424d18a05fd94c6654..37bcf0c16380d28d266eb3cc0105ebc37b28597d 100644
--- a/indra/llrender/llglslshader.cpp
+++ b/indra/llrender/llglslshader.cpp
@@ -157,7 +157,8 @@ void LLGLSLShader::clearStats()
     mSamplesDrawn = 0;
     mDrawCalls = 0;
     mTextureStateFetched = false;
-    mTextureMagMinFilter.clear();
+    mTextureMagFilter.clear();
+    mTextureMinFilter.clear();
 }
 
 void LLGLSLShader::dumpStats()
@@ -170,16 +171,14 @@ void LLGLSLShader::dumpStats()
         {
             LL_INFOS() << mShaderFiles[i].first << LL_ENDL;
         }
-        for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it)
+        for (U32 i = 0; i < mTexture.size(); ++i)
         {
-            S32 i = (*it).first;
-            GLint idx = (*it).second;
+            GLint idx = mTexture[i];
             
             if (idx >= 0)
             {
                 GLint uniform_idx = getUniformLocation(i);
-                magmin_filter_t::iterator it = mTextureMagMinFilter.find(i);
-                LL_INFOS() << mUniformNameMap[uniform_idx] << " - " << std::hex << (*it).second.second << "/" << (*it).second.first << std::dec << LL_ENDL;
+                LL_INFOS() << mUniformNameMap[uniform_idx] << " - " << std::hex << mTextureMagFilter[i] << "/" << mTextureMinFilter[i] << std::dec << LL_ENDL;
             }
         }
         LL_INFOS() << "=============================================" << LL_ENDL;
@@ -236,13 +235,14 @@ void LLGLSLShader::placeProfileQuery()
     if (!mTextureStateFetched)
     {
         mTextureStateFetched = true;
+        mTextureMagFilter.resize(mTexture.size());
+        mTextureMinFilter.resize(mTexture.size());
 
         U32 cur_active = gGL.getCurrentTexUnitIndex();
 
-        for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it)
+        for (U32 i = 0; i < mTexture.size(); ++i)
         {
-            S32 i = (*it).first;
-            GLint idx = (*it).second;
+            GLint idx = mTexture[i];
 
             if (idx >= 0)
             {
@@ -256,7 +256,8 @@ void LLGLSLShader::placeProfileQuery()
                 glGetTexParameteriv(type, GL_TEXTURE_MAG_FILTER, (GLint*) &mag);
                 glGetTexParameteriv(type, GL_TEXTURE_MIN_FILTER, (GLint*) &min);
 
-                mTextureMagMinFilter[i] = magmin_values_t(mag, min);
+                mTextureMagFilter[i] = mag;
+                mTextureMinFilter[i] = min;
             }
         }
 
@@ -414,7 +415,7 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
     for ( ; fileIter != mShaderFiles.end(); fileIter++ )
     {
         GLhandleARB shaderhandle = LLShaderMgr::instance()->loadShaderFile((*fileIter).first, mShaderLevel, (*fileIter).second, &mDefines, mFeatures.mIndexedTextureChannels);
-        LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << " shaderhandle=" << shaderhandle << LL_ENDL;
+        LL_DEBUGS("ShaderLoading") << "SHADER FILE: " << (*fileIter).first << " mShaderLevel=" << mShaderLevel << LL_ENDL;
         if (shaderhandle)
         {
             attachObject(shaderhandle);
@@ -477,14 +478,13 @@ BOOL LLGLSLShader::createShader(std::vector<LLStaticHashedString> * attributes,
         }
 
         S32 cur_tex = channel_count; //adjust any texture channels that might have been overwritten
-        for (uniforms_index_t::iterator it = mTexture.begin(); it != mTexture.end(); ++it)
+        for (U32 i = 0; i < mTexture.size(); i++)
         {
-            int i = (*it).first;
-            if (((*it).second >= 0) && ((*it).second < channel_count))
+            if (mTexture[i] > -1 && mTexture[i] < channel_count)
             {
                 llassert(cur_tex < gGLManager.mNumTextureImageUnits);
                 uniform1i(i, cur_tex);
-                (*it).second = cur_tex++;
+                mTexture[i] = cur_tex++;
             }
         }
         unbind();
@@ -545,7 +545,11 @@ BOOL LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString> * attri
 
     mAttribute.clear();
     U32 numAttributes = (attributes == NULL) ? 0 : attributes->size();
+#if LL_RELEASE_WITH_DEBUG_INFO
+    mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, { -1, NULL });
+#else
     mAttribute.resize(LLShaderMgr::instance()->mReservedAttribs.size() + numAttributes, -1);
+#endif
     
     if (res)
     { //read back channel locations
@@ -559,7 +563,11 @@ BOOL LLGLSLShader::mapAttributes(const std::vector<LLStaticHashedString> * attri
             S32 index = glGetAttribLocationARB(mProgramObject, (const GLcharARB *)name);
             if (index != -1)
             {
+#if LL_RELEASE_WITH_DEBUG_INFO
+                mAttribute[i] = { index, name };
+#else
                 mAttribute[i] = index;
+#endif
                 mAttributeMask |= 1 << i;
                 LL_DEBUGS("ShaderLoading") << "Attribute " << name << " assigned to channel " << index << LL_ENDL;
             }
@@ -659,20 +667,17 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> *
         mUniformMap[hashedName] = location;
 
         LL_DEBUGS("ShaderLoading") << "Uniform " << name << " is at location " << location << LL_ENDL;
-  
+    
         //find the index of this uniform
         for (S32 i = 0; i < (S32) LLShaderMgr::instance()->mReservedUniforms.size(); i++)
         {
-            if (LLShaderMgr::instance()->mReservedUniforms[i] == name)
+            if ( (mUniform[i] == -1)
+                && (LLShaderMgr::instance()->mReservedUniforms[i] == name))
             {
-                std::pair<uniforms_index_t::iterator, bool> result;
-
-                result = mUniform.insert(uniforms_index_t::value_type(i, location));
-                if (result.second)
-                {
-                    mTexture[i] = mapUniformTextureChannel(location, type);
-                    return;
-                }
+                //found it
+                mUniform[i] = location;
+                mTexture[i] = mapUniformTextureChannel(location, type);
+                return;
             }
         }
 
@@ -680,17 +685,13 @@ void LLGLSLShader::mapUniform(GLint index, const vector<LLStaticHashedString> *
         {
             for (U32 i = 0; i < uniforms->size(); i++)
             {
-                std::pair<uniforms_index_t::iterator, bool> result;
-                S32 index = i + LLShaderMgr::instance()->mReservedUniforms.size();
-
-                if ((*uniforms)[i] == hashedName)
+                if ( (mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] == -1)
+                    && ((*uniforms)[i].String() == name))
                 {
-                    result = mUniform.insert(uniforms_index_t::value_type(index, location));
-                    if (result.second)
-                    {
-                        mTexture[index] = mapUniformTextureChannel(location, type);
-                        return;
-                    }
+                    //found it
+                    mUniform[i+LLShaderMgr::instance()->mReservedUniforms.size()] = location;
+                    mTexture[i+LLShaderMgr::instance()->mReservedUniforms.size()] = mapUniformTextureChannel(location, type);
+                    return;
                 }
             }
         }
@@ -730,6 +731,10 @@ BOOL LLGLSLShader::mapUniforms(const vector<LLStaticHashedString> * uniforms)
 	mUniformNameMap.clear();
 	mTexture.clear();
 	mValue.clear();
+	//initialize arrays
+	U32 numUniforms = (uniforms == NULL) ? 0 : uniforms->size();
+	mUniform.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1);
+	mTexture.resize(numUniforms + LLShaderMgr::instance()->mReservedUniforms.size(), -1);
 
 	bind();
 
@@ -929,14 +934,20 @@ S32 LLGLSLShader::bindTexture(const std::string &uniform, LLTexture *texture, LL
 
 S32 LLGLSLShader::bindTexture(S32 uniform, LLTexture *texture, LLTexUnit::eTextureType mode)
 {
-    GLint channel = getTexChannelForIndex(uniform);
+    if (uniform < 0 || uniform >= (S32)mTexture.size())
+    {
+        UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
+        return -1;
+    }
     
-    if (channel > -1)
+    uniform = mTexture[uniform];
+    
+    if (uniform > -1)
     {
-        gGL.getTexUnit(channel)->bind(texture, mode);
+        gGL.getTexUnit(uniform)->bind(texture, mode);
     }
     
-    return channel;
+    return uniform;
 }
 
 S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureType mode)
@@ -949,64 +960,82 @@ S32 LLGLSLShader::unbindTexture(const std::string &uniform, LLTexUnit::eTextureT
 
 S32 LLGLSLShader::unbindTexture(S32 uniform, LLTexUnit::eTextureType mode)
 {
-    GLint channel = getTexChannelForIndex(uniform);
-
-    if (channel > -1)
+    if (uniform < 0 || uniform >= (S32)mTexture.size())
     {
-        gGL.getTexUnit(channel)->unbind(mode);
+        UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
+        return -1;
+    }
+    
+    uniform = mTexture[uniform];
+    
+    if (uniform > -1)
+    {
+        gGL.getTexUnit(uniform)->unbind(mode);
     }
     
-    return channel;
+    return uniform;
 }
 
 S32 LLGLSLShader::enableTexture(S32 uniform, LLTexUnit::eTextureType mode)
 {
-    GLint channel = getTexChannelForIndex(uniform);
-
-    if (channel != -1)
+    if (uniform < 0 || uniform >= (S32)mTexture.size())
+    {
+        UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
+        return -1;
+    }
+    S32 index = mTexture[uniform];
+    if (index != -1)
     {
-        gGL.getTexUnit(channel)->activate();
-        gGL.getTexUnit(channel)->enable(mode);
+        gGL.getTexUnit(index)->activate();
+        gGL.getTexUnit(index)->enable(mode);
     }
-    return channel;
+    return index;
 }
 
 S32 LLGLSLShader::disableTexture(S32 uniform, LLTexUnit::eTextureType mode)
 {
-    GLint channel = getTexChannelForIndex(uniform);
-
-    if (channel != -1 && gGL.getTexUnit(channel)->getCurrType() != LLTexUnit::TT_NONE)
+    if (uniform < 0 || uniform >= (S32)mTexture.size())
+    {
+        UNIFORM_ERRS << "Uniform out of range: " << uniform << LL_ENDL;
+        return -1;
+    }
+    S32 index = mTexture[uniform];
+    if (index != -1 && gGL.getTexUnit(index)->getCurrType() != LLTexUnit::TT_NONE)
     {
-        if (gDebugGL && gGL.getTexUnit(channel)->getCurrType() != mode)
+        if (gDebugGL && gGL.getTexUnit(index)->getCurrType() != mode)
         {
             if (gDebugSession)
             {
-                gFailLog << "Texture channel " << channel << " texture type corrupted." << std::endl;
+                gFailLog << "Texture channel " << index << " texture type corrupted." << std::endl;
                 ll_fail("LLGLSLShader::disableTexture failed");
             }
             else
             {
-                LL_ERRS() << "Texture channel " << channel << " texture type corrupted." << LL_ENDL;
+                LL_ERRS() << "Texture channel " << index << " texture type corrupted." << LL_ENDL;
             }
         }
-        gGL.getTexUnit(channel)->disable();
+        gGL.getTexUnit(index)->disable();
     }
-    return channel;
+    return index;
 }
 
 void LLGLSLShader::uniform1i(U32 index, GLint x)
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+            std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
             if (iter == mValue.end() || iter->second.mV[0] != x)
             {
-                glUniform1iARB(location, x);
-                mValue[location] = LLVector4(x,0.f,0.f,0.f);
+                glUniform1iARB(mUniform[index], x);
+                mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);
             }
         }
     }
@@ -1016,15 +1045,19 @@ void LLGLSLShader::uniform1f(U32 index, GLfloat x)
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+            std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
             if (iter == mValue.end() || iter->second.mV[0] != x)
             {
-                glUniform1fARB(location, x);
-                mValue[location] = LLVector4(x,0.f,0.f,0.f);
+                glUniform1fARB(mUniform[index], x);
+                mValue[mUniform[index]] = LLVector4(x,0.f,0.f,0.f);
             }
         }
     }
@@ -1034,16 +1067,20 @@ void LLGLSLShader::uniform2f(U32 index, GLfloat x, GLfloat y)
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+            std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
             LLVector4 vec(x,y,0.f,0.f);
             if (iter == mValue.end() || shouldChange(iter->second,vec))
             {
-                glUniform2fARB(location, x, y);
-                mValue[location] = vec;
+                glUniform2fARB(mUniform[index], x, y);
+                mValue[mUniform[index]] = vec;
             }
         }
     }
@@ -1053,16 +1090,20 @@ void LLGLSLShader::uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z)
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+            std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
             LLVector4 vec(x,y,z,0.f);
             if (iter == mValue.end() || shouldChange(iter->second,vec))
             {
-                glUniform3fARB(location, x, y, z);
-                mValue[location] = vec;
+                glUniform3fARB(mUniform[index], x, y, z);
+                mValue[mUniform[index]] = vec;
             }
         }
     }
@@ -1072,16 +1113,20 @@ void LLGLSLShader::uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+            std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
             LLVector4 vec(x,y,z,w);
             if (iter == mValue.end() || shouldChange(iter->second,vec))
             {
-                glUniform4fARB(location, x, y, z, w);
-                mValue[location] = vec;
+                glUniform4fARB(mUniform[index], x, y, z, w);
+                mValue[mUniform[index]] = vec;
             }
         }
     }
@@ -1091,16 +1136,20 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v)
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+            std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
             LLVector4 vec(v[0],0.f,0.f,0.f);
             if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
             {
-                glUniform1ivARB(location, count, v);
-                mValue[location] = vec;
+                glUniform1ivARB(mUniform[index], count, v);
+                mValue[mUniform[index]] = vec;
             }
         }
     }
@@ -1110,16 +1159,20 @@ void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v)
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+            std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
             LLVector4 vec(v[0],0.f,0.f,0.f);
             if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
             {
-                glUniform1fvARB(location, count, v);
-                mValue[location] = vec;
+                glUniform1fvARB(mUniform[index], count, v);
+                mValue[mUniform[index]] = vec;
             }
         }
     }
@@ -1129,16 +1182,20 @@ void LLGLSLShader::uniform2fv(U32 index, U32 count, const GLfloat* v)
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+            std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
             LLVector4 vec(v[0],v[1],0.f,0.f);
             if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
             {
-                glUniform2fvARB(location, count, v);
-                mValue[location] = vec;
+                glUniform2fvARB(mUniform[index], count, v);
+                mValue[mUniform[index]] = vec;
             }
         }
     }
@@ -1148,16 +1205,20 @@ void LLGLSLShader::uniform3fv(U32 index, U32 count, const GLfloat* v)
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+            std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
             LLVector4 vec(v[0],v[1],v[2],0.f);
             if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
             {
-                glUniform3fvARB(location, count, v);
-                mValue[location] = vec;
+                glUniform3fvARB(mUniform[index], count, v);
+                mValue[mUniform[index]] = vec;
             }
         }
     }
@@ -1167,16 +1228,20 @@ void LLGLSLShader::uniform4fv(U32 index, U32 count, const GLfloat* v)
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            std::map<GLint, LLVector4>::iterator iter = mValue.find(location);
+            std::map<GLint, LLVector4>::iterator iter = mValue.find(mUniform[index]);
             LLVector4 vec(v[0],v[1],v[2],v[3]);
             if (iter == mValue.end() || shouldChange(iter->second,vec) || count != 1)
             {
-                glUniform4fvARB(location, count, v);
-                mValue[location] = vec;
+                glUniform4fvARB(mUniform[index], count, v);
+                mValue[mUniform[index]] = vec;
             }
         }
     }
@@ -1186,11 +1251,15 @@ void LLGLSLShader::uniformMatrix2fv(U32 index, U32 count, GLboolean transpose, c
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            glUniformMatrix2fvARB(location, count, transpose, v);
+            glUniformMatrix2fvARB(mUniform[index], count, transpose, v);
         }
     }
 }
@@ -1199,11 +1268,15 @@ void LLGLSLShader::uniformMatrix3fv(U32 index, U32 count, GLboolean transpose, c
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
 
-        if (location >= 0)
+        if (mUniform[index] >= 0)
         {
-            glUniformMatrix3fvARB(location, count, transpose, v);
+            glUniformMatrix3fvARB(mUniform[index], count, transpose, v);
         }
     }
 }
@@ -1212,11 +1285,15 @@ void LLGLSLShader::uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose,
 {
 	if (mProgramObject)
 	{	
-        GLint location = getLocationForIndex(index);
+		if (mUniform.size() <= index)
+		{
+			UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+			return;
+		}
 
-		if (location >= 0)
+		if (mUniform[index] >= 0)
 		{
-			glUniformMatrix3x4fv(location, count, transpose, v);
+			glUniformMatrix3x4fv(mUniform[index], count, transpose, v);
 		}
 	}
 }
@@ -1225,10 +1302,15 @@ void LLGLSLShader::uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, c
 {
     if (mProgramObject)
     {   
-        GLint location = getLocationForIndex(index);
-        if (location >= 0)
+        if (mUniform.size() <= index)
+        {
+            UNIFORM_ERRS << "Uniform index out of bounds." << LL_ENDL;
+            return;
+        }
+
+        if (mUniform[index] >= 0)
         {
-            glUniformMatrix4fvARB(location, count, transpose, v);
+            glUniformMatrix4fvARB(mUniform[index], count, transpose, v);
         }
     }
 }
@@ -1259,8 +1341,14 @@ GLint LLGLSLShader::getUniformLocation(const LLStaticHashedString& uniform)
 
 GLint LLGLSLShader::getUniformLocation(U32 index)
 {
-    /*TODO: flatten this... change calls to gUL(U32) */
-    return getLocationForIndex(index);
+    GLint ret = -1;
+    if (mProgramObject)
+    {
+        llassert(index < mUniform.size());
+        return mUniform[index];
+    }
+
+    return ret;
 }
 
 GLint LLGLSLShader::getAttribLocation(U32 attrib)
diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h
index 59edd7b36f0dce5cd572e103e291701bdcd27e7f..0934ceba30ed879f986a9381a24708d0a4b98659 100644
--- a/indra/llrender/llglslshader.h
+++ b/indra/llrender/llglslshader.h
@@ -169,11 +169,6 @@ class LLGLSLShader
 	U32 mMatHash[LLRender::NUM_MATRIX_MODES];
 	U32 mLightHash;
 
-    typedef std::map<S32, GLint> uniforms_index_t;
-    typedef std::pair<U32, U32>  magmin_values_t;
-
-    typedef std::map < S32, magmin_values_t> magmin_filter_t;
-
 	GLhandleARB mProgramObject;
 #if LL_RELEASE_WITH_DEBUG_INFO
 	struct attr_name
@@ -188,12 +183,11 @@ class LLGLSLShader
 	std::vector<GLint> mAttribute; //lookup table of attribute enum to attribute channel
 #endif
 	U32 mAttributeMask;  //mask of which reserved attributes are set (lines up with LLVertexBuffer::getTypeMask())
-    uniforms_index_t mUniform;
-    uniforms_index_t mTexture;
-
+	std::vector<GLint> mUniform;   //lookup table of uniform enum to uniform location
 	LLStaticStringTable<GLint> mUniformMap; //lookup map of uniform name to uniform location
 	std::map<GLint, std::string> mUniformNameMap; //lookup map of uniform location to uniform name
 	std::map<GLint, LLVector4> mValue; //lookup map of uniform location to last known value
+	std::vector<GLint> mTexture;
 	S32 mTotalUniformSize;
 	S32 mActiveTextureChannels;
 	S32 mShaderLevel;
@@ -217,32 +211,13 @@ class LLGLSLShader
 	static U32 sTotalDrawCalls;
 
 	bool mTextureStateFetched;
-    magmin_filter_t mTextureMagMinFilter;
+	std::vector<U32> mTextureMagFilter;
+	std::vector<U32> mTextureMinFilter;
 
     GLhandleARB mExtraLinkObject = 0;
 
 private:
 	void unloadInternal();
-
-    inline GLint getLocationForIndex(S32 index)
-    {
-        if (!mProgramObject)
-            return -1;
-        uniforms_index_t::iterator it = mUniform.find(index);
-        if (it == mUniform.end())
-            return -1;
-        return (*it).second;
-    }
-
-    inline GLint getTexChannelForIndex(S32 index)
-    {
-        if (!mProgramObject)
-            return -1;
-        uniforms_index_t::iterator it = mTexture.find(index);
-        if (it == mTexture.end())
-            return -1;
-        return (*it).second;
-    }
 };
 
 //UI shader (declared here so llui_libtest will link properly)
diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 9067a17bafc6d1424e696881f64b237676facc51..5e16aded302dc6301c9300ec257b08db3a279d4a 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1267,7 +1267,7 @@ void LLRender::syncMatrices()
 				}
 
 				shader->uniformMatrix4fv(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX, 1, GL_FALSE, cached_mvp.m);
-			}            
+			}
 		}
 
 		i = MM_PROJECTION;
diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h
index ceebc7000bfbdd3da1148242990f33b4e019cf84..1bc5e89eacaa497708a2b82644f6bd37dfcc3b95 100644
--- a/indra/llrender/llrender.h
+++ b/indra/llrender/llrender.h
@@ -446,7 +446,7 @@ class LLRender
 	static U32 sUICalls;
 	static U32 sUIVerts;
 	static bool sGLCoreProfile;
-    static bool sNsightDebugSupport;
+	static bool sNsightDebugSupport;
 
 private:
 	friend class LLLightState;
@@ -503,11 +503,6 @@ const F32 OGL_TO_CFR_ROTATION[16] = {  0.f,  0.f, -1.f,  0.f, 	// -Z becomes X
 									   0.f,  1.f,  0.f,  0.f,	//  Y becomes Z
 									   0.f,  0.f,  0.f,  1.f };
 
-const F32 XYZ_TO_OGL_ROTATION[16] = {  1.f,  0.f,  0.f,  0.f, 	//  X stays    X
-									   0.f,  0.f, -1.f,  0.f, 	//  Z becomes -Y
-									   0.f,  1.f,  0.f,  0.f,	//  Y becomes  Z
-									   0.f,  0.f,  0.f,  1.f };
-
 glh::matrix4f copy_matrix(F32* src);
 glh::matrix4f get_current_modelview();
 glh::matrix4f get_current_projection();
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp
index 544a4f00aab0ae4c9367dc3244b787c0e5454da1..1eb1cb56a858aeb271b1723feaf99bd268076e31 100644
--- a/indra/llrender/llshadermgr.cpp
+++ b/indra/llrender/llshadermgr.cpp
@@ -985,7 +985,7 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade
 		// Add shader file to map
 		mShaderObjects[filename] = ret;
 		shader_level = try_gpu_class;
-    }
+	}
 	else
 	{
 		if (shader_level > 1)
@@ -1150,7 +1150,7 @@ void LLShaderMgr::initAttribsAndUniforms()
 	mReservedUniforms.push_back("cloud_noise_texture");
 	mReservedUniforms.push_back("fullbright");
 	mReservedUniforms.push_back("lightnorm");
-	mReservedUniforms.push_back("sunlight_color");
+	mReservedUniforms.push_back("sunlight_color_copy");
 	mReservedUniforms.push_back("ambient");
 	mReservedUniforms.push_back("blue_horizon");
 	mReservedUniforms.push_back("blue_density");
diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h
index fa2a9f03be4e17b4301aa3703246c0ab1c3789be..9919dbe31a7926b95741ac2f34115d6ab72b18af 100644
--- a/indra/llrender/llshadermgr.h
+++ b/indra/llrender/llshadermgr.h
@@ -30,11 +30,6 @@
 #include "llgl.h"
 #include "llglslshader.h"
 
-/*RIDER: TODO:
- * This should use the LL Singleton<> template... but not a quick conversion.
- * (llviewershadermgr derives from this)
- */
-
 class LLShaderMgr
 {
 public:
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp
index a33f84518ffffe84c58952842831eb1747a0a0a1..e3e605d040aae7aa7ed8bc808520e5bfe3ede00c 100644
--- a/indra/llrender/llvertexbuffer.cpp
+++ b/indra/llrender/llvertexbuffer.cpp
@@ -198,7 +198,7 @@ volatile U8* LLVBOPool::allocate(U32& name, U32 size, bool for_seed)
 		}
 		else
 		{ //always use a true hint of static draw when allocating non-client-backed buffers
-            glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB);
+			glBufferDataARB(mType, size, 0, GL_STATIC_DRAW_ARB);
 		}
 
 		glBindBufferARB(mType, 0);
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp
index 2650f69a2f41179a12b66fe8898e366c1a3dcc82..b7aff6bca917d309958fbc80966dcc59220fac3a 100644
--- a/indra/newview/llenvironment.cpp
+++ b/indra/newview/llenvironment.cpp
@@ -125,8 +125,8 @@ namespace
     class LLTrackBlenderLoopingTime : public LLSettingsBlenderTimeDelta
     {
     public:
-        LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, F64Seconds cyclelength, F64Seconds cycleoffset) :
-            LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), F64Seconds(1.0)),
+        LLTrackBlenderLoopingTime(const LLSettingsBase::ptr_t &target, const LLSettingsDay::ptr_t &day, S32 trackno, LLSettingsBase::Seconds cyclelength, LLSettingsBase::Seconds cycleoffset) :
+            LLSettingsBlenderTimeDelta(target, LLSettingsBase::ptr_t(), LLSettingsBase::ptr_t(), LLSettingsBase::Seconds(1.0)),
             mDay(day),
             mTrackNo(0),
             mCycleLength(cyclelength),
@@ -156,7 +156,7 @@ namespace
             mTrackTransitionStart = mTarget->buildDerivedClone();
             mTrackNo = use_trackno;
 
-            F64Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE;
+            LLSettingsBase::Seconds now = getAdjustedNow() + LLEnvironment::TRANSITION_ALTITUDE;
             LLSettingsDay::TrackBound_t bounds = getBoundingEntries(now);
 
             LLSettingsBase::ptr_t pendsetting = (*bounds.first).second->buildDerivedClone();
@@ -189,7 +189,7 @@ namespace
             return 1;
         }
 
-        LLSettingsDay::TrackBound_t getBoundingEntries(F64Seconds time)
+        LLSettingsDay::TrackBound_t getBoundingEntries(LLSettingsBase::Seconds time)
         {
             LLSettingsDay::CycleTrack_t &wtrack = mDay->getCycleTrack(mTrackNo);
             F64 position = convertTimeToPosition(time);
@@ -198,19 +198,19 @@ namespace
             return bounds;
         }
 
-        F64Seconds getAdjustedNow() const
+        LLSettingsBase::Seconds getAdjustedNow() const
         {
-            F64Seconds now(LLDate::now().secondsSinceEpoch());
+            LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch());
 
             return (now + mCycleOffset);
         }
 
-        F64Seconds                  getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const
+        LLSettingsBase::Seconds getSpanTime(const LLSettingsDay::TrackBound_t &bounds) const
         {
             return mCycleLength * get_wrapping_distance((*bounds.first).first, (*bounds.second).first);
         }
 
-        F64                         convertTimeToPosition(F64Seconds time)
+        F64 convertTimeToPosition(LLSettingsBase::Seconds time)
         {
             F64 position = static_cast<F64>(fmod(time.value(), mCycleLength.value())) / static_cast<F64>(mCycleLength.value());
             return llclamp(position, 0.0, 1.0);
@@ -219,14 +219,14 @@ namespace
     private:
         LLSettingsDay::ptr_t        mDay;
         S32                         mTrackNo;
-        F64Seconds                  mCycleLength;
-        F64Seconds                  mCycleOffset;
+        LLSettingsBase::Seconds     mCycleLength;
+        LLSettingsBase::Seconds     mCycleOffset;
         LLSettingsBase::ptr_t       mTrackTransitionStart;
 
         void                        onFinishedSpan()
         {
             LLSettingsDay::TrackBound_t next = getBoundingEntries(getAdjustedNow());
-            F64Seconds nextspan = getSpanTime(next);
+            LLSettingsBase::Seconds nextspan = getSpanTime(next);
             reset((*next.first).second, (*next.second).second, nextspan.value());
         }
     };
@@ -442,7 +442,7 @@ bool LLEnvironment::getIsMoonUp() const
 }
 
 //-------------------------------------------------------------------------
-void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, F64Seconds transition, bool forced)
+void LLEnvironment::setSelectedEnvironment(LLEnvironment::EnvSelection_t env, LLSettingsBase::Seconds transition, bool forced)
 {
     mSelectedEnvironment = env;
     updateEnvironment(transition, forced);
@@ -472,7 +472,7 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getEnvironmentInstance(LLEnviro
 }
 
 
-void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset)
+void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset)
 {
     if ((env < ENV_EDIT) || (env >= ENV_DEFAULT))
     {   
@@ -525,8 +525,8 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, const LLSe
 
     if (settings->getSettingType() == "daycycle")
     {
-        S64Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH);
-        S64Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET);
+        LLSettingsDay::Seconds daylength(LLSettingsDay::DEFAULT_DAYLENGTH);
+        LLSettingsDay::Seconds dayoffset(LLSettingsDay::DEFAULT_DAYOFFSET);
         if (environment)
         {
             daylength = environment->getDayLength();
@@ -583,12 +583,12 @@ LLSettingsDay::ptr_t LLEnvironment::getEnvironmentDay(LLEnvironment::EnvSelectio
     return LLSettingsDay::ptr_t();
 }
 
-S64Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env)
+LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env)
 {
     if ((env < ENV_EDIT) || (env > ENV_DEFAULT))
     {
         LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL;
-        return S64Seconds(0);
+        return LLSettingsDay::Seconds(0);
     }
 
     DayInstance::ptr_t environment = getEnvironmentInstance(env);
@@ -596,22 +596,22 @@ S64Seconds LLEnvironment::getEnvironmentDayLength(EnvSelection_t env)
     if (environment)
         return environment->getDayLength();
 
-    return S64Seconds(0);
+    return LLSettingsDay::Seconds(0);
 }
 
-S64Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env)
+LLSettingsDay::Seconds LLEnvironment::getEnvironmentDayOffset(EnvSelection_t env)
 {
     if ((env < ENV_EDIT) || (env > ENV_DEFAULT))
     {
         LL_WARNS("ENVIRONMENT") << "Attempt to retrieve invalid environment selection." << LL_ENDL;
-        return S64Seconds(0);
+        return LLSettingsDay::Seconds(0);
     }
 
     DayInstance::ptr_t environment = getEnvironmentInstance(env);
     if (environment)
         return environment->getDayOffset();
 
-    return S64Seconds(0);
+    return LLSettingsDay::Seconds(0);
 }
 
 
@@ -670,7 +670,7 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::getSelectedEnvironmentInstance(
 }
 
 
-void LLEnvironment::updateEnvironment(F64Seconds transition, bool forced)
+void LLEnvironment::updateEnvironment(LLSettingsBase::Seconds transition, bool forced)
 {
     DayInstance::ptr_t pinstance = getSelectedEnvironmentInstance();
 
@@ -1365,9 +1365,9 @@ LLEnvironment::EnvironmentInfo::ptr_t LLEnvironment::EnvironmentInfo::extract(LL
     if (environment.has("region_id"))
         pinfo->mRegionId = environment["region_id"].asUUID();
     if (environment.has("day_length"))
-        pinfo->mDayLength = S64Seconds(environment["day_length"].asInteger());
+        pinfo->mDayLength = LLSettingsDay::Seconds(environment["day_length"].asInteger());
     if (environment.has("day_offset"))
-        pinfo->mDayOffset = S64Seconds(environment["day_offset"].asInteger());
+        pinfo->mDayOffset = LLSettingsDay::Seconds(environment["day_offset"].asInteger());
     if (environment.has("day_hash"))
         pinfo->mDayHash = environment["day_hash"].asInteger();
     if (environment.has("day_cycle"))
@@ -1643,7 +1643,7 @@ LLEnvironment::DayInstance::DayInstance() :
     mSkyTrack(1)
 { }
 
-void LLEnvironment::DayInstance::update(F64Seconds delta)
+void LLEnvironment::DayInstance::update(LLSettingsBase::Seconds delta)
 {
     if (!mInitialized)
         initialize();
@@ -1659,7 +1659,7 @@ void LLEnvironment::DayInstance::update(F64Seconds delta)
 //         mWater->update();
 }
 
-void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset)
+void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset)
 {
     if (mType == TYPE_FIXED)
         LL_WARNS("ENVIRONMENT") << "Fixed day instance changed to Cycled" << LL_ENDL;
@@ -1750,7 +1750,7 @@ void LLEnvironment::DayInstance::setBlenders(const LLSettingsBlender::ptr_t &sky
     mBlenderWater = waterblend;
 }
 
-F64 LLEnvironment::DayInstance::secondsToKeyframe(S64Seconds seconds)
+F64 LLEnvironment::DayInstance::secondsToKeyframe(LLSettingsDay::Seconds seconds)
 {
     F64 frame = static_cast<F64>(seconds.value() % mDayLength.value()) / static_cast<F64>(mDayLength.value());
 
@@ -1759,7 +1759,7 @@ F64 LLEnvironment::DayInstance::secondsToKeyframe(S64Seconds seconds)
 
 void LLEnvironment::DayInstance::animate()
 {
-    F64Seconds now(LLDate::now().secondsSinceEpoch());
+    LLSettingsBase::Seconds now(LLDate::now().secondsSinceEpoch());
 
     now += mDayOffset;
 
@@ -1807,7 +1807,7 @@ void LLEnvironment::DayInstance::animate()
 
 //-------------------------------------------------------------------------
 LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart,
-    const LLSettingsWater::ptr_t &waterstart, LLEnvironment::DayInstance::ptr_t &end, S64Seconds time) :
+    const LLSettingsWater::ptr_t &waterstart, LLEnvironment::DayInstance::ptr_t &end, LLSettingsDay::Seconds time) :
     DayInstance(),
     mStartSky(skystart),
     mStartWater(waterstart),
@@ -1817,7 +1817,7 @@ LLEnvironment::DayTransition::DayTransition(const LLSettingsSky::ptr_t &skystart
     
 }
 
-void LLEnvironment::DayTransition::update(F64Seconds delta)
+void LLEnvironment::DayTransition::update(LLSettingsBase::Seconds delta)
 {
     mNextInstance->update(delta);
     DayInstance::update(delta);
diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h
index 0fbc49bc7d0e88553304fc47e003bd589668ee2b..52f22ac8f15fb9784ceb35be689df3e33723e6d6 100644
--- a/indra/newview/llenvironment.h
+++ b/indra/newview/llenvironment.h
@@ -62,15 +62,15 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
 
         typedef std::shared_ptr<EnvironmentInfo>  ptr_t;
 
-        S32                 mParcelId;
-        LLUUID              mRegionId;
-        S64Seconds          mDayLength;
-        S64Seconds          mDayOffset;
-        size_t              mDayHash;
-        LLSD                mDaycycleData;
-        std::array<F32, 4>  mAltitudes;
-        bool                mIsDefault;
-        bool                mIsRegion;
+        S32                     mParcelId;
+        LLUUID                  mRegionId;
+        LLSettingsDay::Seconds  mDayLength;
+        LLSettingsDay::Seconds  mDayOffset;
+        size_t                  mDayHash;
+        LLSD                    mDaycycleData;
+        std::array<F32, 4>      mAltitudes;
+        bool                    mIsDefault;
+        bool                    mIsRegion;
 
 
         static ptr_t        extract(LLSD);
@@ -152,11 +152,11 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
     void                        updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);
     void                        updateShaderUniforms(LLGLSLShader *shader);
 
-    void                        setSelectedEnvironment(EnvSelection_t env, F64Seconds transition = TRANSITION_DEFAULT, bool forced = false);
+    void                        setSelectedEnvironment(EnvSelection_t env, LLSettingsBase::Seconds transition = TRANSITION_DEFAULT, bool forced = false);
     EnvSelection_t              getSelectedEnvironment() const                  { return mSelectedEnvironment; }
 
     bool                        hasEnvironment(EnvSelection_t env);
-    void                        setEnvironment(EnvSelection_t env, const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset);
+    void                        setEnvironment(EnvSelection_t env, const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset);
     void                        setEnvironment(EnvSelection_t env, fixedEnvironment_t fixed);
     void                        setEnvironment(EnvSelection_t env, const LLSettingsBase::ptr_t &fixed); 
     void                        setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixed) { setEnvironment(env, fixedEnvironment_t(fixed, LLSettingsWater::ptr_t())); }
@@ -164,13 +164,13 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
     void                        setEnvironment(EnvSelection_t env, const LLSettingsSky::ptr_t & fixeds, const LLSettingsWater::ptr_t & fixedw) { setEnvironment(env, fixedEnvironment_t(fixeds, fixedw)); }
     void                        clearEnvironment(EnvSelection_t env);
     LLSettingsDay::ptr_t        getEnvironmentDay(EnvSelection_t env);
-    S64Seconds                  getEnvironmentDayLength(EnvSelection_t env);
-    S64Seconds                  getEnvironmentDayOffset(EnvSelection_t env);
+    LLSettingsDay::Seconds      getEnvironmentDayLength(EnvSelection_t env);
+    LLSettingsDay::Seconds      getEnvironmentDayOffset(EnvSelection_t env);
     fixedEnvironment_t          getEnvironmentFixed(EnvSelection_t env);
     LLSettingsSky::ptr_t        getEnvironmentFixedSky(EnvSelection_t env)      { return getEnvironmentFixed(env).first; };
     LLSettingsWater::ptr_t      getEnvironmentFixedWater(EnvSelection_t env)    { return getEnvironmentFixed(env).second; };
 
-    void                        updateEnvironment(F64Seconds transition = TRANSITION_DEFAULT, bool forced = false);
+    void                        updateEnvironment(LLSettingsBase::Seconds transition = TRANSITION_DEFAULT, bool forced = false);
 
     void                        addSky(const LLSettingsSky::ptr_t &sky);
     void                        addWater(const LLSettingsWater::ptr_t &sky);
@@ -253,9 +253,9 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
                                     DayInstance();
         virtual                     ~DayInstance() { };
 
-        virtual void                update(F64Seconds);
+        virtual void                update(LLSettingsBase::Seconds);
 
-        void                        setDay(const LLSettingsDay::ptr_t &pday, S64Seconds daylength, S64Seconds dayoffset);
+        void                        setDay(const LLSettingsDay::ptr_t &pday, LLSettingsDay::Seconds daylength, LLSettingsDay::Seconds dayoffset);
         void                        setSky(const LLSettingsSky::ptr_t &psky);
         void                        setWater(const LLSettingsWater::ptr_t &pwater);
 
@@ -269,8 +269,8 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
         LLSettingsDay::ptr_t        getDayCycle() const     { return mDayCycle; }
         LLSettingsSky::ptr_t        getSky() const          { return mSky; }
         LLSettingsWater::ptr_t      getWater() const        { return mWater; }
-        S64Seconds                  getDayLength() const    { return mDayLength; }
-        S64Seconds                  getDayOffset() const    { return mDayOffset; }
+        LLSettingsDay::Seconds      getDayLength() const    { return mDayLength; }
+        LLSettingsDay::Seconds      getDayOffset() const    { return mDayOffset; }
         S32                         getSkyTrack() const     { return mSkyTrack; }
 
         virtual void                animate();
@@ -286,14 +286,14 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
         InstanceType_t              mType;
         bool                        mInitialized;
 
-        S64Seconds                  mDayLength;
-        S64Seconds                  mDayOffset;
+        LLSettingsDay::Seconds      mDayLength;
+        LLSettingsDay::Seconds      mDayOffset;
         S32                         mLastTrackAltitude;
 
         LLSettingsBlender::ptr_t    mBlenderSky;
         LLSettingsBlender::ptr_t    mBlenderWater;
 
-        F64                         secondsToKeyframe(S64Seconds seconds);
+        F64                         secondsToKeyframe(LLSettingsDay::Seconds seconds);
     };
     typedef std::array<DayInstance::ptr_t, ENV_END> InstanceArray_t;
 
@@ -301,17 +301,17 @@ class LLEnvironment : public LLSingleton<LLEnvironment>
     class DayTransition : public DayInstance
     {
     public:
-                                    DayTransition(const LLSettingsSky::ptr_t &skystart, const LLSettingsWater::ptr_t &waterstart, DayInstance::ptr_t &end, S64Seconds time);
+                                    DayTransition(const LLSettingsSky::ptr_t &skystart, const LLSettingsWater::ptr_t &waterstart, DayInstance::ptr_t &end, LLSettingsDay::Seconds time);
         virtual                     ~DayTransition() { };
 
-        virtual void                update(F64Seconds);
+        virtual void                update(LLSettingsBase::Seconds);
         virtual void                animate();
 
     protected:
         LLSettingsSky::ptr_t        mStartSky;
         LLSettingsWater::ptr_t      mStartWater;
         DayInstance::ptr_t          mNextInstance;
-        S64Seconds                  mTransitionTime;
+        LLSettingsDay::Seconds      mTransitionTime;
     };
 
     static const F32            SUN_DELTA_YAW;
diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp
index 706dd99fc9752e428c52d18e97eb1f3b658d6505..543f6e567147bda095d2181b8386124df63cf0eb 100644
--- a/indra/newview/llfloatereditextdaycycle.cpp
+++ b/indra/newview/llfloatereditextdaycycle.cpp
@@ -192,7 +192,7 @@ void LLFloaterEditExtDayCycle::onOpen(const LLSD& key)
     {
         S32Hours hrs;
         S32Minutes minutes;
-        S64Seconds total;
+        LLSettingsDay::Seconds total;
         LLUIString formatted_label = getString("time_label");
         for (int i = 0; i < max_elm; i++)
         {
@@ -700,7 +700,7 @@ void LLFloaterEditExtDayCycle::updateTimeAndLabel()
     {
         LLUIString formatted_label = getString("time_label");
 
-        S64Seconds total = (mDayLength  * time); 
+        LLSettingsDay::Seconds total = (mDayLength  * time); 
         S32Hours hrs = total;
         S32Minutes minutes = total - hrs;
 
diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h
index bee5e17b95c2fe1aed65a761d3f4b8e70a12d917..fc0b4f5106a0b2e6802c813c6693e667f7427772 100644
--- a/indra/newview/llfloatereditextdaycycle.h
+++ b/indra/newview/llfloatereditextdaycycle.h
@@ -138,7 +138,7 @@ class LLFloaterEditExtDayCycle : public LLFloater
     static void onIdlePlay(void *);
 
     LLSettingsDay::ptr_t    mEditDay; // edited copy
-    S64Seconds              mDayLength;
+    LLSettingsDay::Seconds  mDayLength;
     U32                     mCurrentTrack;
     std::string             mLastFrameSlider;
 
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index 39dada19842300f4138c39c740244a30160e5dbe..ac472534440dcbfc25233b0764eb6d1548966afd 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -3325,7 +3325,7 @@ void LLPanelLandEnvironment::doApply()
     }
     else
     {
-        S64Seconds daylength;
+        LLSettingsDay::Seconds daylength;
         F32Hours   dayoffset_h;
 
         daylength = F32Hours(mDayLengthSlider->getValueF32());
@@ -3336,7 +3336,7 @@ void LLPanelLandEnvironment::doApply()
             dayoffset_h = F32Hours(24.0f) + dayoffset_h;
         }
 
-        S64Seconds dayoffset_s = dayoffset_h;
+        LLSettingsDay::Seconds dayoffset_s = dayoffset_h;
 
         LLEnvironment::instance().updateParcel(parcel_id, mEditingDayCycle, daylength.value(), dayoffset_s.value());
     }
diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp
index 272ac8a1bba25ae7e56165134de6f9e4e5d03997..6719e6ed3b9b59fbbab42c024ece52142b7f2a7b 100644
--- a/indra/newview/llfloaterregioninfo.cpp
+++ b/indra/newview/llfloaterregioninfo.cpp
@@ -3426,7 +3426,7 @@ void LLPanelRegionEnvironment::doApply()
     }
     else
     {
-        S64Seconds daylength;
+        LLSettingsDay::Seconds daylength;
         F32Hours   dayoffset_h;
 
         daylength = F32Hours(mDayLengthSlider->getValueF32());
@@ -3437,7 +3437,7 @@ void LLPanelRegionEnvironment::doApply()
             dayoffset_h = F32Hours(24.0f) + dayoffset_h;
         }
 
-        S64Seconds dayoffset_s = dayoffset_h;
+        LLSettingsDay::Seconds dayoffset_s = dayoffset_h;
 
         LLEnvironment::instance().updateRegion(mEditingDayCycle, daylength.value(), dayoffset_s.value());
     }