Backported updates from Titta (https://github.com/jackuess/titta)