Use of else if, should be elseif
Unused variables and tidying up.
Added spaces.
Tidying up, including docblock fixes.