Dlh optimization

Have made as many optimizations as I could identify. Please do let me know if more optimizations can be identified. This scheme is highly dependent of statistics of individual documents which makes it a hard candidate for optimization.