Fixed bug when maximizing a window on Windows (was introduced recently)
Fixed undefined behavior of returned pointer
Fixed some uninitialized values
Avoid const_cast, static buffer and buffer overlap