Changed keyfile handling and added Python 2.7 support