I implemented simple fixes for the two issues #1 and #2 which follow the style of the other code. Only a few lines have been edited. Please check and if OK then merge into master.