Added code to get matrices and shadowmaps from lights.

Also did some template code for `fmap` and `flatten`. Could be useful
later on.
Added some comments.