cleanup gradient code