More small tweaks

Hello again Shish,

Some more small tweaks, mostly along the lines of using '===' in place of '==' where possible, and computing count($var) outside of the for-loop, etc.

These changes should merge fine without any issues.

Thanks!  :3