Pull request for fixing the bugs #1005, #1006, #1007

Accomplishing the announced pull request.