Fixed memory leaks and added support for non-ARC projects

Fixed memory leaks and added support for non-ARC projects