Fix a memory leak. We need to clean up our autorelease pool code at some point.
Fixed logic bug.