Memory leak and Linux build fixed