Fix #297 with proposed changes after review