Crash fix. Accessing freed memory