fix glfw on Mingw32 and general cleaning
add support for std::ref for type erasure