fixed some free bugs