added some options, fixed comments, added some file and directory checks