Fixed hit range function
Some minor changes