Fix a bug that was causing the wrong hit layer number to be returned by the function getLayer