Some code cleanup, lock in freemap