Modified version of https://github.com/starburst1977/readium