Reworked truncate(), optimized code

Optimized connection instances and directory listing.