Fix issues 51 and 52

This pull request provides fixes/enhancements for issues 51 and 52. It also addresses at least part of xenserver/xenserver-core issue 327.

This is my first pull request so let me know if I should do something different like do the pull request to one of the branches.