Adding documentation and cleaning up the targets_are_valid method