Use the cost array itself to work out which squares have/haven't been visited yet instead of storing that information in a separate bit-array. On my CPU, this gives a ~12% speedup. It also uses less RAM. :)