Initial port; minimal tests, but passing