Fix for #655

Fix for #655, possibly also #647 (I will confirm if this is fixed when it is merged in)