Fix some issues

This pull request fix some issues from the bug tracker.