Implemented truncation. Code style fixes. Refactored common unlink helper.