refactored to use glib types and thus remove need for handrolled dynamic array