Enhancements

Hi. I was just browsing code to see how it works and made couple of changes. And I have decided to offer them back. Thanks for your work, it is greatly appreciated.