adding fixes for custom directory and some error exiting