fixed symlink support and some refactoring