Correct freeing of properties, some bugs fixed