Refactoring valid handle detection into its own method.
Adding some preliminary documentation.
Replacing simple check with valid_handle? check.