Modified to use sha512 where necessary