minor cleanup and added mechanism to automatically create the required
directories if they don't exist yet.