Added directory compression and cleaned up the code a bit.