step2: fixed free mem double.
minor compile fixes - linux