Added nested calls.
Fixed memory leak.