General code cleanup & use of pythonic code style