added better error logging and fixed parent publish dir generation