Fix for Issue 485 and 493.

This is the first time I am contributing to an open source project.  Looking for more guidance and also looking forward to make more contribution in future.