Sorted out layout so figures and tables appear near their references.