Bug fixes for Qt5