Changed parameter presence check

Changed the method for checking the presence of the 'pid' parameter to
avoid mysql notices being output. Also added some commenting to the
code.