Initial port from Javascript.