Few enhancements...

- Added a check to validate d once it had been calculated.
- Size checked e on program execution.