Fix #331 (partially)