initial release. ported from java.