fix #306 and #313

Hmm not sure this is what you asked