Mostly heavy refactoring, iOS7+

Refactoring to fit more modern style. replacing many lines of code with
simpler alternatives. I will be trying to use this in a project. It
might end up very different from the original. It now will only work
with iOS7