cleanup of scan key building