Fixing bugs in file/dir and some refactoring in authentication/chain

Signed-off-by: Alexander Book <redchrome@gmx.de>