synced with https://github.com/BlueSpire/Durandal/commit/52da05d80b57f42416507db49fc29996422d2810