Fixes #751

Sorry for the mess in the commits :p