Now evaluates everything correctly. Also, correctly deletes pointers.