added export function (generic), and fixed #1