lots of changes due to new OO foreign interface