Fix memory leak in chunk saving
Better error handling
Actually lock the locks...

Turns out locking is a useful feature of locks, who knew?