First (hopefully) working version of caption processing.