Added samba support and fix some bugs