Fix inconsistent return statements

This pull request fixes some inconsistent return statements by using the more explicit `return null;` and other small changes.