ported more of the original Java model, see #15