Code cleanup, formatting. Constructor now support a captions object