Initial implementations of selecting a definition number
Fix bugs and handle exceptions correctly