Added shape marking envelope creation and inside checking