Fixes #395

Should also fix #396, fix #394, fix #393, fix #392