Fixes #27. Damn, that was tough to debug!