Fixed memory leaks and added support for non-ARC projects