Added key file logic, documentation