Workaround GCC bug #54526 (Part of #11)
Use our own version of std::to_string (Part of #11)
Add some static_casts to make GCC 4.7.x happy (Part of #11)