got all the essential primitives working; need to fix leaks, though