r3: Added error reporting and directory scanning.