switch to a callback API to save mallocs and memcpys
refs #18