Use confess for some internal errors

Also added a file existance check to sha512_sum
Fixed path to file for sha512_sum for legacy packages
Added some consistency checks and additional debug messages