fixed #609 and also made sure that layer.clear() also clears the hit context