Fixed folder modification order and handles exceptions if folder is in use