synced with https://github.com/BlueSpire/Durandal/commit/ca0c158ef788e4cf29b799a755a1d21367ca2505