Comments, Whitespace and Type hinting

Commented each function, it's parameters and return type.
Additional whitespace where appropriate
Removed checks for a function being an array as the type hinting will solve that issue.