more code import (and modifications to make tests pass)