Added file/directory support

Created checks for files and directories and did some cleaning up