Some fixes for an Xcode update that hated some int to long conversions