Don't break if calling hasLayer with null. Fixes #170. Thanks @l0c0luke