Added freelist and tests