copy from smallfish