this fixes #218 and more