Remove an unnecessary null check
Implement paramater type check and refactor some redundant null checks
Add assertions