optimizations, bug fixes, refactoring, removed non-ARC code