OPT: Made the following changes.
1. Used np.unravel_index
2. Improved docs and removed unused imports.