First attempt at making the code Python3-compatible