Fixed a few bugs in perimeter_in.m