Fixed bugs with sample key location and generation