Reworked ownership detection, added error message

Included the 'current unused key' detection in the ownership check of the address, and added a throw error if the address is foreign.