Upgraded to ARC. Fixed some bugs