fixes a part of #106
fixes #117 and some additional issues

fixed some swapped boolean constraints