improved unix build process - reduced time by about 15%
fixed a potential memory leak
added a fflush() to log calls, just to make sure that the ordering is correct