Really fix $MONITOR_PORT detection

Fixes issue #215
Merge pull request #216 from sej7278/master

Really fix $MONITOR_PORT detection. Fix #215
Made all the changes into one commit that could be a patch for master