Restructure code, implement exception report for iOS, fix bugs