fixes #306 and fixes #307