Corrected assertion.
Fixed - though extremely suboptimal, and size-limited.
Added locking.
Fixed permissions.