port from amalgamatic project