Added capturing, although probably not in the most elegant way (closes #13).