fixed bugs created from switching between pythone 2 and python 3