This code follows the BSD license.