fixed some issues with keyfile reading