More fixes for 7e08788/#28, needs testing