Fix weird encoding problems and figure references