Cleaning up A-star

Removing some commented-out code that needs further work, and adding a
few sanity checks to avoid runtime errors and worst-case scenarios.