Fixed minor code errors.

Logic was missing to handle invalid folder.