Small tweaks to be more compatible to Python 3
Cheking of optional values, and cosmetic changes