#86 Fixed check to prevent division by 0
#86 Improvements on coding style and documentation