various capture code cleanup and fixes: