Internal restructoring, qt5 support and fixed some crashes