Updated database saving/loading and format

- Cleaned up the code a bit
- Some sanity checks are stricter
- Object fields have been put in a more natural order
- Added locks field
Added experimental sanity editor