Updated the whole metadata system.

I have moved the whole metadata system to a file based system except for
the chat stuff but I might move it later. It is not too important.
Done for the night. Not sure how much has changed in this version so
feel free to have a look throught the commit.
Look through the commit. Too much to list.
.