minor reablity and locale support changes
more constness, use bool when appropriate, variable definition cleanup and scoping fixes