Fixed key file reading, added some comments