Added missing imports, catching more exceptions.
Modified config reading and sanitizeUser to make more sense.