Added the cone check and polished the overall code a bit