moved some code around, added better error messaging for missing image directories.