Fixed some bugs, removed giant try-catch loop.