Fixed #318

* Fixed typo in line 362
Removed useless keys in two foreach loops

* Removed $categoryID in line 498
* Removed $tagID in line 511
Merge pull request #319 from frmwrk123/fix/318

Fixed typo and improved code