Working version of iOS side; also many hacks included