Fixed symlink peeling.
Minor fixes and optimizations.