fixed key creation bugs