Hopefully fix all unix build errors and fixed also some bugs