Split settings into seperate source and header files

This also cleans up settings a bit
Fix locking bugs and make inventory deserialization errors more specific