fix ARC compatibility and clean code