Fixed #4, among other things