More bugfixes to defineShape rewrite