Minor fixes

- Fix the type issue in leakage calculation

- Some trivial improvements in the code