Not terribly happy with how the code looks after, though. Change-Id: I7bf5f78ef6c0ac82339a2e49488ca6e64d13c05e