Migrate to Arc and add autoreleasepool

Fixes #337