Fixed crash under 10.9. Fixed some memory leaks.